package com.ljx.funchat.user.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum WSPushTypeEnum {

    PERSON(1, "个人"),
    ALL(2, "全体");

    private Integer type;
    private String desc;

    private static Map<Integer, WSPushTypeEnum> cache;

    static {
        cache = Arrays.stream(WSPushTypeEnum.values()).collect(Collectors.toMap(WSPushTypeEnum::getType, Function.identity()));
    }


    public static WSPushTypeEnum of(Integer pushType) {
        for (WSPushTypeEnum pushTypeEnum : WSPushTypeEnum.values()) {
            if (pushTypeEnum.getType().equals(pushType)){
                return pushTypeEnum;
            }
        }
        return null;
    }
}
